package com.message.push.provider.rs.impl;

import com.message.push.provider.actor.MessagePush;
import com.message.push.provider.common.Result;
import com.message.push.provider.model.MessageInfo;
import com.message.push.provider.rs.MessagePushRS;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class MessagePushRSImpl implements MessagePushRS {

    private final ObjectProvider<MessagePush> messageSenderObjectProvider;

    public MessagePushRSImpl(ObjectProvider<MessagePush> messageSenderObjectProvider) {
        this.messageSenderObjectProvider = messageSenderObjectProvider;
    }

    @Override
    public Result<Boolean> support(String supplier) {
        return Result.build(messageSenderObjectProvider.stream().anyMatch(messagePush -> messagePush.support(supplier)));
    }
}
